package shop.controls;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import shop.pojo.Caterage;
import shop.services.CaterageService;

/**
 * Servlet implementation class CaterageAdd
 */
public class CaterageAdd extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CaterageAdd() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String strC_name = request.getParameter("c_name");
		Caterage caterage = new Caterage();
		caterage.setC_name(strC_name);
		int i = new CaterageService().insertintoCaterage(caterage);
		if(i>0){
			request.getRequestDispatcher("CaterageSel.do").forward(request, response);
		}else{
			response.sendRedirect("jsp2/categoryAdd.jsp");
		}
	}

}
